import {getProjectOpsFile} from '../../../utils/OpsFile.js';
import {runNbGo} from '../../nb-go/index.js';

export const goMixin = {
    async handleGoCommand() {
        try {
            await this.ensureOpsClient(false);
            if (!this.projectOpsFile) {
                this.assignProjectOpsFile(getProjectOpsFile());
            }
            this.logger.info('开始执行 NB GO 流程');
            await runNbGo(this);
            this.logger.success('NB GO 流程已执行完成');
        } catch (error) {
            const message = error?.message ?? '未知错误';
            const finalMessage = message.includes('请手动处理') ? message : `${message}，请手动处理`;
            this.logger.error(`NB GO 流程执行失败: ${finalMessage}`);
            throw new Error(finalMessage);
        }
    },
};
